using System;
using System.IO;
using System.Text;
using System.Resources;
using System.Globalization;
using System.Xml.Serialization;

namespace CSF.Communications.Sdp.ServiceLogic.Entities
{
	/// <summary>
	/// Summary description for ModifyStateResponse.
	/// </summary>
	[XmlRootAttribute("ModifyStateResponse",IsNullable=false,Namespace="http://www.microsoft.com/csf/20/wes")]
	[Serializable]
	public class ModifyStateResponse: ModifyStateBase
	{
		
		#region members
      
		private string state;
        private string target;
        private string identifier;
        private VasRequestInternalParameters parameters;
		private string resultCode;
		private string errorMessage;
		private const int DefaultResultCode = 0;
		    
		#endregion
      
		#region ModifyStateResponse

		/// <summary>
		/// Constructor
		/// </summary>
		public ModifyStateResponse()
		{
            parameters = new VasRequestInternalParameters();
			
		}
		#endregion

		#region ModifyStateResponse(ModifyStateRequest)
		/// <summary>
		/// Constructor Overloaded
		/// </summary>
		public ModifyStateResponse(ModifyStateRequest request)
		{
			base.Target = request.Target;
			base.Identifier = request.Identifier;
			state = request.EndState;
			parameters = new VasRequestInternalParameters();         
			//parameters = new VasResponseParameters(request);         
			resultCode = DefaultResultCode.ToString(CultureInfo.InvariantCulture);
		}
		#endregion

		#region ModifyStateResponse(ModifyStateRequest,bool)
		/// <summary>
		/// Constructor Overloaded
		/// </summary>
		public ModifyStateResponse(ModifyStateRequest request,bool isEndProvision)
		{
			if(isEndProvision)
			{
				base.Target = request.Target;
				base.Identifier = request.Identifier;
				state = request.EndState;
                parameters = new VasRequestInternalParameters();		
				//parameters = new VasResponseParameters(request);         
				resultCode = DefaultResultCode.ToString(CultureInfo.InvariantCulture);
			}
		}
		#endregion

		#region SerializeObject
		/// <summary>
		/// This method returns an xml representation of the object
		/// </summary>
		/// <returns>The xml resprestation as Srting</returns>
		public string SerializeObject()
		{
			StringBuilder serialBuilder ;
			StringWriter serialWriter ;
			XmlSerializer messageSerializer;
			try
			{
				serialBuilder = new StringBuilder(1000);
				serialWriter = 
					new StringWriter(serialBuilder,CultureInfo.InvariantCulture);
				messageSerializer = new XmlSerializer(this.GetType());
				messageSerializer.Serialize(serialWriter,this);
				return serialWriter.ToString();
			}
			catch(Exception serializeObjectException )
			{
				throw (serializeObjectException );
			}
			finally
			{
				serialBuilder = null;
				serialWriter  = null;
				messageSerializer = null;
			}
		}
		#endregion

		#region Properties
      
		/// <summary>
		/// Get / Set property for startState
		/// </summary>
		[XmlElement("State",Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
		public string State
		{
			get
			{
				return  state;
			}

			set
			{
				state= value ;
			}
		}

        /// <summary>
        /// Get / Set property for startState
        /// </summary>
        [XmlElement("Target", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string Target
        {
            get
            {
                return target;
            }

            set
            {
                target = value;
            }
        }

        /// <summary>
        /// Get / Set property for startState
        /// </summary>
        [XmlElement("Identifier", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string Identifier
        {
            get
            {
                return identifier;
            }

            set
            {
                identifier = value;
            }
        }

		/// <summary>
		/// Get / Set property for parameters
		/// </summary>
		[XmlElement("Parameters",Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public VasRequestInternalParameters Parameters
		{
			get
			{
				return parameters;
			}
			set
			{
				parameters = value;
			}
		}

		/// <summary>
		/// Get / Set property for resultCode
		/// </summary>
		[XmlElement("ResultCode",Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
		public string ResultCode
		{
			get
			{
				return  resultCode;
			}

			set
			{
				resultCode = value ;
			}
		}

		/// <summary>
		/// Get / Set property for errorMessage
		/// </summary>
		[XmlElement("ErrorMessage",Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
		public string ErrorMessage
		{
			get
			{
				return  errorMessage;
			}

			set
			{
				errorMessage= value ;
			}
		}


        #region DeSerializeObject
        /// <summary>
        /// This method returns an xml representation of the object
        /// </summary>
        /// <returns>The xml representation as Srting</returns>
        public static ModifyStateResponse DeSerializeObject(String xmlString)
        {
            StringReader serialReader;
            XmlSerializer messageSerializer;
            ModifyStateResponse csfMid = null;

            try
            {
                serialReader = new StringReader(xmlString);
                messageSerializer = new XmlSerializer(typeof(ModifyStateResponse));
                csfMid = (ModifyStateResponse)messageSerializer.Deserialize(serialReader);

            }
            catch (Exception serializeObjectException)
            {
                throw (serializeObjectException);
            }
            finally
            {
                messageSerializer = null;
            }

            return csfMid;
        }
        #endregion
      
      
		#endregion    
	}
}
